<template>
  <div class="download">
    <header v-if="isMobile">
      <router-link :to="obAccessKey?'/pools/dashboard':'/'"><i class="icon-back iconfont"></i></router-link>
      {{$t('download.1')}}
    </header>
    <div class="mask" v-if="isWechat">
      <p>{{$t('download.2')}} {{isIOS ? 'Safari' : $t('download.3')}} {{$t('download.4')}}</p>
      <img :src="require('@/assets/images/download/alert-arrow.png')" />
    </div>
    <div class="appicon">
      <img :src="require('@/assets/images/download/app.png')" />
    </div>
    <div class="button" @click="download">
      <i class="iconfont icon-download"></i>{{$t('download.5')}}
    </div>
    <br>
    <div class="info">
      {{$t('download.6')}} {{isIOS ? 'iOS' : 'android'}} {{$t('download.7')}}
    </div>
  </div>
</template>
<script>
import { androidDownloadURL, iosDownloadURL } from '@/api/baseURL';
import { isMobile, isIOS, isAndroid, isWechat } from '@/utils/judgingUA';
import { mapGetters } from 'vuex';

export default {
  name: 'download',
  data() {
    return {
      isMobile: isMobile(),
      isWechat: isWechat(),
      isIOS: isIOS(),
      isAndroid: isAndroid(),
    };
  },
  computed: {
    ...mapGetters(['obAccessKey']),
  },
  beforeCreate() {
    if (isMobile()) {
      window.document.querySelector('#app').style.minWidth = 'auto';
      // if (isIOS()) {
      //   window.location.href = wapUrl;
      // }
    }
  },
  destroyed() {
    if (isMobile()) {
      window.document.querySelector('#app').style.minWidth = '1200px';
    }
  },
  methods: {
    download() {
      window.location.href = (this.isIOS ? iosDownloadURL : androidDownloadURL);
    },
  },
};
</script>
<style lang="scss" scoped>
.download{
  text-align: center;
  header{
    height: 1.333333rem;
    line-height: 1.333333rem;
    background-color: #fff;
    box-shadow: 0px 0px .066667rem 0px rgba(0, 0, 0, 0.05);
    border-bottom: solid 1px #e0e0e0;
    color: #76c1b3;
    font-size: 18px;
    position: relative;
    text-align: center;
    a{
      position: absolute;
      left: .4rem;
      color: #76c1b3;
      font-size: 24px;
    }
  }
  .mask{
    background: rgba(52, 52, 52, 0.9);
    padding-top: 50px;
    font-size: 14px;
    line-height: 1.6;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    p{
      padding-right: 50px;
      padding-left: 30px;
      color: #7f7e7e;
    }
    img{
      width: 30px;
      margin-top: -68px;
      float: right;
      margin-right: 15px;
    }
  }
  .appicon{
    width: 120px;
    height: 120px;
    border-radius: 24px;
    border: 1px solid #ddd;
    margin: 100px auto 0;
  }
  .button{
    font-size: 18px;
    background-color: #1abc9c;
    cursor: pointer;
    color: #fff;
    margin: 50px auto 0;
    padding: 10px 25px;
    display: inline-block;
    text-align: center;
    i{
      margin-right: 5px;
    }
  }
  .info{
    background-color: #5bc0de;
    font-size: 12px;
    color: #fff;
    padding: 3px 7px;
    display: inline-block;
    text-align: center;
    border-radius: .25em;
    margin: 10px auto 0;
  }
}
</style>
